package edu.zhang.front.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import edu.zhang.dao.CustomerDAO;
import edu.zhang.dao.TypeDAO;
import edu.zhang.po.Customer;
import edu.zhang.po.Type;

@WebServlet("/customer/CustomerSubmit")
public class CustomerSubmit extends HttpServlet {
	private static final long serialVersionUID = 1L;
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String account = request.getParameter("account");

		CustomerDAO customerDAO = new CustomerDAO();
		Customer customer = customerDAO.getCustomerByAccount(account);

		if (customer != null) {
			request.setAttribute("customer", customer);
			request.getRequestDispatcher("usercenter.jsp").forward(request, response);
		} else {
			response.sendRedirect("error.jsp");
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		this.doGet(request, response);
	}

}
